//
//  UIBarButtonItem+Extension.swift
//  Mircore
//
//  Created by apple on 16/8/8.
//  Copyright © 2016年 飞羽. All rights reserved.
//

import UIKit


extension   UIBarButtonItem  {


//便利构造函数创建UIBarButtonItem类型的对象
    
    convenience  init(title: String, target:AnyObject?,action: Selector) {
        
        //使用self调用其他构造函数
        
        self.init()
        
        let button = UIButton ()
        
        //添加点击事件
        
        button.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        
        button.setTitle(title, forState: .Normal)
        
        button.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        
        button.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        
        button.titleLabel?.font  = UIFont.systemFontOfSize(15)
        
        button.sizeToFit()
        
        //设置自定义视图
        customView  = button
        
        
       
    }

}